﻿Namespace Commanding
    Public Class CommandCommand
        Inherits Command

        Public Shared ReadOnly ICommandProperty As DependencyProperty = DependencyProperty.Register("ICommand", GetType(ICommand), GetType(CommandCommand))
        Public Property ICommand As ICommand
            Get
                Return GetValue(ICommandProperty)
            End Get
            Set(ByVal value As ICommand)
                SetValue(ICommandProperty, value)
            End Set
        End Property

        Public Overrides Function CanExecute(parameter As Object) As Boolean
            Dim result As Boolean = False
            If ICommand IsNot Nothing Then
                result = ICommand.CanExecute(parameter)
            End If
            Return result
        End Function

        Public Overrides Sub Execute(parameter As Object)
            If ICommand IsNot Nothing Then
                ICommand.Execute(parameter)
            End If
        End Sub

        Protected Overrides Function CreateInstanceCore() As System.Windows.Freezable
            Return New CommandCommand
        End Function
    End Class
End Namespace